app.controller("readCoverCtrl",function($scope,$state,$http,$ionicLoading,$stateParams){
    var user_info = JSON.parse(localStorage.getItem("UserInfo"));
    // var getPath = JSON.parse(localStorage.getItem("getPath"));
    angular.element(document).ready(function () {

        //数据绑定
        var url = getPath.url+getPath.name+"/app/getCycleAndBook";
        var param = {
            userId:user_info.userId,
        }
        if(!$stateParams.queryDate){
            param.queryDate = new Date().Format("yyyy-MM-dd");
        }else {
            param.queryDate = $stateParams.queryDate;
        }
        localStorage.setItem("queryDate",param.queryDate);
        $http({
            url: url,
            method: "POST",
            headers:{'Content-Type':'application/x-www-form-urlencoded'},
            data: param
        }).success(function (data) {
                if (data.resultCode == 200) {
                    var bookInfo = data.resultBean[0];
                    //阅读顺序
                    $scope.taskOrder = bookInfo.taskOrder;
                    //书籍阅读中的总阅读天数
                    $scope.nTotalTaskDate = bookInfo.nTotalTaskDate;
                    //书名
                    $scope.bookName = bookInfo.bookName;
                    //出版社
                    $scope.press = bookInfo.press;
                    //作者
                    $scope.author = bookInfo.author;
                    //阅读时间
                    $scope.preReadTime = bookInfo.preReadTime;
                    localStorage.setItem("preReadTime",bookInfo.preReadTime);
                    localStorage.setItem("bookInfo",JSON.stringify(bookInfo));
                }
            })
            .error(function () {
                $ionicLoading.hide();
                $ionicLoading.show({
                    template: "获取读书计划失败",
                    duration: 3000
                });
            });
    });
    $scope.openCatalog = function () {
        $state.go("home.read-catalog",{
            queryDate : $stateParams.queryDate
        });
    }
});